package com.echo.neocommunity.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.echo.neocommunity.mapper.MessageMapper;
import com.echo.neocommunity.pojo.Message;
import com.echo.neocommunity.pojo.MyPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements IService<Message> {

    @Autowired
    private MessageMapper messageMapper;

    public List<Message> findConversation(int userId,int offset,int limit){
        return messageMapper.selectConversations(userId, offset, limit);
    }
    public int findConversationCount(int userId){
        return messageMapper.selectConversationCount(userId);
    }

    public List<Message> selectLetters(String conversationId,int offset,int limit) {
        return messageMapper.selectLetters(conversationId, offset, limit);
    }

    public int selectLetterCount(String conversationId){
        return messageMapper.selectLetterCount(conversationId);
    }

    public int selectLetterUnreadCount(int userId,String conversationId){
        return messageMapper.selectLetterUnreadCount(userId, conversationId);
    }


    //查询某个主题下的最新通知
    public Message selectLastNotice(int userId,String topic){
        return messageMapper.selectLastNotice(userId, topic);
    }
    //查询某个主题下包含的数量
    public int messageCount(int userId,String topic){
        return messageMapper.MessageCount(userId, topic);
    }
    //查询未读数量
    public int messageUnreadCount(int userId,String topic){
        return messageMapper.MessageUnreadCount(userId, topic)==null?0:messageMapper.MessageUnreadCount(userId, topic);
    }

    //查询某个主题下的所有通知
    public List<Message> selectAllNotice(int userId,String topic,int offset,int limit){
        return messageMapper.selectAllNotice(userId, topic, offset, limit);
    }





}
